<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-MELANGE.
 *
 * PHP-MELANGE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-MELANGE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-MELANGE; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-melange
 * @subpackage  cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */
?>
<?=$this->header(true)?>


    <?=$this->menu("requests")?>


    <h1><?=$this->message("label.header", _Request::BUNDLE)?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.header", _Request::BUNDLE),
                "href"=>"request/index"
            ),
            array(
                "name"=>($this->requestForm->getRequest()->getRequestId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE) . " " .
                        "\"".$this->requestForm->getRequest()->getFirstname()." ".$this->requestForm->getRequest()->getSurname()."\" " :
                    $this->message("route.new", _Core::BUNDLE) . " " . $this->message("label.item", _Request::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Request::BUNDLE)?>


    <form id="<?=get_class($this->requestForm)?>" action="request/save" method="post" enctype="multipart/form-data">

        <div>
            <input type="hidden"
                   name="request->requestId"
                   value="<?=$this->requestForm->getRequest()->getRequestId()?>" />
        </div>

        <fieldset>

            <legend><?=$this->message("label.required", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("request->firstname")?>">
                <th><label for="request_firstname"><?=$this->message("prompt.firstname", _Request::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="request->firstname"
                           id="request_firstname"
                           value="<?=$this->requestForm->getRequest()->getFirstname()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("request->surname")?>">
                <th><label for="request_surname"><?=$this->message("prompt.surname", _Request::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="request->surname"
                           id="request_surname"
                           value="<?=$this->requestForm->getRequest()->getSurname()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("request->email")?>">
                <th><label for="request_email"><?=$this->message("prompt.email", _Request::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="request->email"
                           id="request_email"
                           value="<?=$this->requestForm->getRequest()->getEmail()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("request->subject")?>">
                <th><label for="request_subject"><?=$this->message("prompt.subject", _Request::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="request->subject"
                           id="request_subject"
                           value="<?=$this->requestForm->getRequest()->getSubject()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("request->sentTo")?>">
                <th><label for="request_sentTo"><?=$this->message("prompt.to", _Request::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="request->sentTo"
                           id="request_sentTo"
                           value="<?=$this->requestForm->getRequest()->getSentTo()?>"
                           maxlength="255"
                           type="text"
                           class="textInput"
                           readonly="readonly" />
                </td>
            </tr>
            </table>

        </fieldset>

        <fieldset>

            <legend><?=$this->message("label.optional", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("request->comment")?>">
                <th><label for="request_comment"><?=$this->message("prompt.comment", _Request::BUNDLE)?></label></th>
                <th class="required"><em>&nbsp;</em></th>
                <td>
                    <textarea id="request_comment" name="request->comment" rows="20" cols="80"><?=!is_null($this->requestForm->getRequest()->getComment()) ? htmlspecialchars($this->requestForm->getRequest()->getComment()->getContents()) : ""?></textarea>
                </td>
            </tr>
            </table>

        </fieldset>

        <div class="buttons">

            <input type="button"
                   onclick="to('request/index')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>

    <?=$this->focus(get_class($this->requestForm), "request->firstname")?>

<?=$this->footer()?>